package com.gofun.framework.dubbo.core.environment.config;

import com.gofun.framework.dubbo.core.environment.ConfigMapping;
import com.gofun.framework.dubbo.core.environment.ResolveMappingStrategy;
import com.gofun.framework.dubbo.core.environment.DefaultResolveStrategy.ResolveStrategyEnum;

/**
 * @Project       : framework-dubbo-core
 * @Program Name  : com.ljt.framework.dubbo.core.environment.property.ApplicationDubboEnum.java
 * @Description   : <dubbo:reference/> 服务消费者引用服务配置
 * @Author        : wangchao
 * @Creation Date : 2016年5月27日 下午4:04:50 
 * @ModificationHistory  
 * Who          When             What 
 * ----------   -------------    -----------------------------------
 * wangchao     2016年5月27日        create
 */
public enum ReferenceConfigEnum implements ConfigMapping {
	
	VERSION("dubbo.reference.version","服务版本，与服务提供者的版本一致"),
	
	GROUP("dubbo.reference.group","服务分组，当一个接口有多个实现，可以用分组区分，必需和服务提供方一致"),
	
	TIMEOUT("dubbo.reference.timeout","远程服务调用超时时间(毫秒),缺省使用<dubbo:consumer>的timeout"),
	
	DEFAULT_URL("dubbo.reference.url","点对点直连服务提供者地址，将绕过注册中心,使用该配置项目中所有的远程依赖都将使用这一个地址,如果有多个远程依赖此配置不适用",DEV_ACTIVATED),
	
	URL("url","点对点直连服务提供者地址，将绕过注册中心,针对每个接口设置一个远程依赖连接地址",ResolveStrategyEnum.P2P.resolve,DEV_ACTIVATED),
	
	RETRIES("dubbo.reference.retries","远程服务调用重试次数，不包括第一次调用，不需要重试请设为0,缺省使用<dubbo:consumer>的retries"),
	
	CHECK("dubbo.reference.check","启动时检查提供者是否存在，true报错，false忽略,缺省使用dubbo:consumer的check"),
	
	;
	
	public String code;
	
	public String text;
	
	public String[] activated; 
	
	public ResolveMappingStrategy resolveMapping;
	
	private ReferenceConfigEnum(String code,String text) {
		this(code, text,ResolveStrategyEnum.DIRECT.resolve, ALL_ACTIVATED);
	}
	
	private ReferenceConfigEnum(String code,String text,String... activated) {
		this(code, text, ResolveStrategyEnum.DIRECT.resolve, activated);
	}
	
	private ReferenceConfigEnum(String code,ResolveMappingStrategy resolveMapping,String text) {
		this(code, text, resolveMapping, ALL_ACTIVATED);
	}
	
	private ReferenceConfigEnum(String code,String text,ResolveMappingStrategy resolveMapping,String... activated) {
		this.code = code;
		this.text = text;
		this.activated = activated;
		this.resolveMapping = resolveMapping;
	}
	
	@Override
	public ResolveMappingStrategy getResolveMapping() {
		return resolveMapping;
	}
	
	public String[] getActivated() {
		return activated;
	}
	
	@Override
	public String getCode() {
		return code;
	}

	@Override
	public String getText() {
		return text;
	}

}
